#include <iostream>
#include <cmath>
#include "StarAndMap.h"
using namespace std;

void civ::balance()
{
    int temp=0;
    for(int i1=0;i1<owned;i1+=1)
    {
        temp+=(own[i1]->pop)*(own[i1]->res)*science;
    }
    income=temp;
    resource+=int(income);
};//获取结余资源

void civ::population()
{
    for(int i1=0;i1<owned;i1+=1)//人口增长
    {
        if(own[i1]->pop<=own[i1]->poplim/2)
        {
            own[i1]->growth+=own[i1]->pop*(pop_upkeep-0.2);
        }
        else
        {
            own[i1]->growth+=(own[i1]->poplim/2)*(pop_upkeep-0.2)-0.3*((own[i1]->pop)-(own[i1]->poplim/2));
        }
        if(own[i1]->growth>100)
        {
            own[i1]->pop+=1;
            own[i1]->growth=0;
        }
    }
    int temp=0;//人口核算
    for(int i1=0;i1<owned;i1+=1)
    {
        temp+=own[i1]->pop;
    }
    total_pop=temp;
}
